cmake_minimum_required(VERSION 2.8) #проверка версии cmake

set(PROJECT scon) #присваиваем переменной PROJECT значение libscon

project(${PROJECT}) #задаем имя проекта

#aux_source_directory("./sources" SOURCES) #добавляем список исходников из папки sources в переменную SOURCES


macro(add_app_executable BUILD_TYPE) #макрос задающий тип сборки проекта
	if(${BUILD_TYPE} STREQUAL "debug_test")
		set(EXECUTABLE_OUTPUT_PATH "./debug_tests")
		include_directories("./include" "C:/gtest")
		link_directories("C:/gtest")
		aux_source_directory("./test" SOURCES_TEST)
		aux_source_directory("./sources" SOURCES_TEST)
		add_executable(${PROJECT}_test ${SOURCES_TEST})
		set_target_properties(${PROJECT}_test PROPERTIES COMPILE_FLAGS "-O0 -g3 -D__SCON_DEBUG__ -D__SCON_TEST__ -Wall")
		target_link_libraries(${PROJECT}_test libgtest.a libgtest_main.a)
		run_test(${PROJECT}_test)
		#enable_testing()
		#add_test(NAME ${PROJECT}_test
			#COMMAND ${PROJECT}_test
			#WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})

	endif()
endmacro()

add_custom_target(test)
macro(run_test TEST_TARGET)
	add_custom_target(${TEST_TARGET}_runtest
		COMMAND ${TEST_TARGET}
		DEPENDS ${TEST_TARGET}
		WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
	add_dependencies(test ${TEST_TARGET}_runtest)
endmacro()

add_app_executable(debug_test)

#enable_testing()
